package com.passioneffect.widgets {
	import flash.display.DisplayObject;
	
	import gs.TweenMax;			

	/**
	 * @author Passion Effect
	 */
	public class Fade {
		//set the original alpha as original alpha, then open to tween to talpha, close to tween back to original alpha
		protected var _time:Number=0.2;
		protected var _target : DisplayObject;
		protected var _randomStart:Number=0;
		protected var oalpha:Number = 0;
		private var talpha : Number;

		public function Fade(mc:DisplayObject,time:Number=0.2,alpha:Number=1,randomStart:Number=0) {
			this._target=mc;
			this._time=time;
			this._randomStart=randomStart;
			this.oalpha=_target.alpha;
			this.talpha=alpha;
			
		}
		
		public function open():void{
			TweenMax.to(_target,_time,{alpha:talpha,delay:_randomStart*Math.random()});
		}
		
		public function close():void{
			TweenMax.to(_target,_time,{alpha:oalpha,delay:_randomStart*Math.random()});
		}
		
	}
}
